//
//  KAMineHeader.swift
//  kano
//
//  Created by Sophia on 2024/8/21.
//

import UIKit

class KAMineHeader: UIView {

    lazy var var_iconButton: UIButton = {
        let var_iconButton = UIButton()
        var_iconButton.setImage(UIImage(named: "mine_icon"), for: .normal)
        var_iconButton.isUserInteractionEnabled = false
        var_iconButton.frame = CGRectMake(kscale(20), kscale(30), kscale(56), kscale(56))
        return var_iconButton
    }()
    lazy var var_nameLabel: UILabel = {
        let var_nameLabel = UILabel()
        var_nameLabel.font = UIFont.systemFont(ofSize: kscale(24), weight: .bold)
        var_nameLabel.textColor = .themeColor
        var_nameLabel.text = "Hello"
        var_nameLabel.textAlignment = .left
        return var_nameLabel
    }()
    
    lazy var var_phoneLabel: UILabel = {
        let var_emailLabel = UILabel()
        var_emailLabel.font = UIFont.systemFont(ofSize: kscale(13))
        var_emailLabel.textColor = .color8A8891
        var_emailLabel.text = KAUserManager.shared.user.mobile
        var_emailLabel.textAlignment = .left
        return var_emailLabel
    }()
    
    lazy var var_limitView: KALimitPlate = {
        let width = (var_screenWidth - kscale(48))/2
        let var_limitView = KALimitPlate(CGRectMake(kscale(20), var_cornerView.bottom+kscale(12), width, kscale(80)))
        return var_limitView
    }()
    lazy var var_bankAccView: KABankPlate = {
        let var_bankAccView = KABankPlate(title:"Bank account", CGRectMake(var_limitView.right+kscale(8), var_limitView.top, var_limitView.width, kscale(80)))
        return var_bankAccView
    }()
    lazy var var_bankCardView: KABankPlate = {
        let var_bankCardView = KABankPlate(title:"Bank card", CGRectMake(var_limitView.right+kscale(8), var_bankAccView.bottom+kscale(8), var_limitView.width, kscale(36)))
        return var_bankCardView
    }()
    
    
    lazy var var_cornerView: UIView = {
        let var_cornerView = UIView()
        var_cornerView.backgroundColor = .colorFFEAD6
        var_cornerView.frame = CGRectMake(kscale(20),var_iconButton.bottom + kscale(18), var_screenWidth-kscale(40), kscale(50))
        var_cornerView.layer.cornerRadius = kscale(16)
        var_cornerView.layer.masksToBounds = true
        return var_cornerView
    }()
    lazy var var_cellImg: UIImageView = {
        let var_cellImg = UIImageView(frame: CGRectMake(var_cornerView.left+kscale(12), kscale(13), kscale(24), kscale(24)))
        var_cellImg.image = UIImage(named: "mine_msg")
        return var_cellImg
    }()
    lazy var var_titleLabel: UILabel = {
        let var_titleLabel = UILabel()
        var_titleLabel.font = UIFont.systemFont(ofSize: kscale(16), weight: .regular)
        var_titleLabel.textColor = .colorEE7B33
        var_titleLabel.text = "My bill"
        var_titleLabel.frame = CGRectMake(var_cellImg.right+kscale(8), var_cellImg.top, kscale(80), kscale(18))
        var_titleLabel.centerY = var_cellImg.centerY
        return var_titleLabel
    }()
    
    lazy var var_arrowImg: UIImageView = {
        let var_arrowImg = UIImageView(image: UIImage(named: "mine_arrow"))
        var_arrowImg.size = CGSize(width: kscale(24), height: kscale(24))
        var_arrowImg.centerY = var_cellImg.centerY
        var_arrowImg.right = var_cornerView.right-kscale(36)
        return var_arrowImg
    }()
    
    init() {
        super.init(frame: CGRectMake(0, 0, var_screenWidth, kscale(268)))
        ka_setUI()
    }
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}

extension KAMineHeader {
    func ka_setUI() {
        backgroundColor = .white
        addSubview(var_iconButton)
        addSubview(var_nameLabel)
        addSubview(var_phoneLabel)
        
        addSubview(var_cornerView)
        var_cornerView.addSubview(var_cellImg)
        var_cornerView.addSubview(var_titleLabel)
        var_cornerView.addSubview(var_arrowImg)

        addSubview(var_limitView)
        addSubview(var_bankAccView)
        //addSubview(var_bankCardView)

        var_nameLabel.snp.makeConstraints { make in
            make.top.equalTo(var_iconButton.snp.top).offset(kscale(4.5))
            make.left.equalTo(var_iconButton.snp.right).offset(kscale(12))
        }
        var_phoneLabel.snp.makeConstraints { make in
            make.bottom.equalTo(var_iconButton.snp.bottom).offset(kscale(-4.5))
            make.left.equalTo(var_iconButton.snp.right).offset(kscale(12))
        }

    }
  
}
